<?php

class Default_Controllers_Vote extends Libs_Controller {

    function __construct() {
        parent::__construct();
    }

    public function voteUp($id) {
//        $id = $_POST['id'];
        $voteUp = new Default_Models_Vote();
        $insert = $voteUp->insertThumbUp($id);
        $up = $voteUp->getThumbUp($id);
        if ($insert == TRUE) {
            echo $up . "<script>document.getElementById('mess').innerHTML='Cảm ơn bạn đã vote!';</script>";
//            $this->view->render('vote/index');
        } else {
            echo $up . "<script>document.getElementById('mess').innerHTML='Bạn đã vote rồi!';</script>";
//            $this->view->render('vote/index');
        }
    }

    public function voteDown($id) {
        $voteDown = new Default_Models_Vote();
        $insert = $voteDown->insertThumbDown($id);
        $down = $voteDown->getThumbDown($id);
        if ($insert == TRUE) {
            echo $down . "<script>document.getElementById('mess').innerHTML='Cảm ơn bạn đã vote!';</script>";
        } else {
            echo $down . "<script>document.getElementById('mess').innerHTML='Bạn đã vote rồi!';</script>";
        }
    }

}
